<template>
  <view class="index">
    <view class="jtop">
      <view class="status_bar"><!-- 这里是状态栏 --></view>
      <view class="jtop_l" @tap="navigateBack"
        ><image src="../../static/img/ic_back.png"></image
      ></view>
      <view class="jtop_c ell">{{ lssj.name }}</view>
      <view class="jtop_r" @click="jshow_pop"
        ><image src="../../static/img/doc/ic_ellipsis.png"></image
      ></view>
    </view>

    <view class="tophr"></view>

    <view class="content"> </view>
    <view class="dd">
      <image
        v-if="(lssj.suffix = 'png')"
        :src="lssj.url"
        class="doc_bl"
      ></image>
      <image
        v-else-if="(lssj.suffix = 'jpg')"
        :src="lssj.url"
        class="doc_bl"
      ></image>
      <image
        v-else-if="(lssj.suffix = 'jpeg')"
        :src="lssj.url"
        class="doc_bl"
      ></image>
      <image
        v-else-if="(lssj.suffix = 'gif')"
        :src="lssj.url"
        class="doc_bl"
      ></image>
      <image
        v-else-if="(lssj.suffix = 'ico')"
        :src="lssj.url"
        class="doc_bl"
      ></image>

      <web-view
        class="jdoc"
        v-else
        :webview-styles="webviewStyles"
        :src="'http://view.officeapps.live.com/op/view.aspx?src=' + lssj.url"
      ></web-view>
    </view>

    <!-- 弹出层 -->
    <view :class="[ashowpop ? 'tc' : 'tc hide']">
      <view class="jtop_bj" @click="jshow_pop"></view>

      <view class="tc_fbox">
        <view class="ddf">
          <image src="../../static/img/doc/ic_transpond_1.png"></image>
          <text>转发</text>
        </view>
        <view class="ddf">
          <form @submit="formSubmit" @reset="formReset">
            <input class="uni-input" name="title" placeholder="文章标题" />
            <input class="uni-input" name="miaoshu" placeholder="文章描述" />
            <input class="uni-input" name="imgurl" placeholder="图片地址" />
            <input class="uni-input" name="url" placeholder="跳转链接" />
            <!-- <button formType="submit">分享到微信群或好友</button> -->
            <button class="fjsext" formType="submit">
              <image src="../../static/img/doc/ic_wechat.png"></image>
              <text>分享到微信</text>
            </button>
          </form>
        </view>
        <view class="ddf">
          <image src="../../static/img/doc/ic_other.png"></image>
          <text>用其他应用打开</text>
        </view>
        <view class="tc_fbox_bt" @click="jshow_pop">
          取消
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import request from '@/common/request.js';
import { mapState } from 'vuex';

export default {
  computed: mapState(['forcedLogin', 'hasLogin', 'userName']),
  data() {
    return {
      repeat_click: true,
      ashowpop: false,
      lssj: uni.getStorageSync('lssj'),
      webviewStyles: {
        progress: {
          color: '#FF3333',
        },
      },
    };
  },
  methods: {
    formSubmit: function(e) {
      var title = e.detail.value.title;
      var miaoshu = e.detail.value.miaoshu;
      var imgurl = e.detail.value.imgurl;
      var url = e.detail.value.url;
      console.log(title);
      uni.share({
        provider: 'weixin',
        scene: 'WXSceneSession',
        type: 0,
        href: url,
        title: title,
        summary: miaoshu,
        imageUrl: imgurl,
        success: function(res) {
          console.log(JSON.stringify(res));
          this.repeat_click = true;
          uni.showToast({
            title: '已分享',
            duration: 2000,
          });
        },

        fail: function(err) {
          var errrr = JSON.stringify(err);
          if (errrr) {
            uni.showModal({
              title: '表单不能留空',
              content: '请完善所有信息再发起分享',
              success: function(res) {
                if (res.confirm) {
                  console.log('用户点击确定');
                } else if (res.cancel) {
                  console.log('用户点击取消');
                }
              },
            });
          }
        },
      });
    },

    jshow_pop() {
      this.ashowpop = !this.ashowpop;
    },
    navigateBack() {
      uni.navigateBack();
    },
  },
};
</script>

<style>
.tophr {
  width: 100%;
  height: 88rpx;
}
.dd {
  width: 690rpx;
  height: auto;
  float: left;
  margin: 28rpx 30rpx;
  font-size: 24rpx;
  line-height: 36rpx;
  color: #666666;
}

.tc {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  display: block;
}
.jtop_bj {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
}
.tc_fbox_bt {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 20rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #f2f2f2;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 10001;
}

.ddf {
  width: 120rpx;
  height: auto;
  display: block;
  float: left;
  margin: 60rpx 0 0 30rpx;
}
.ddf image {
  width: 112rpx;
  height: 112rpx;
  display: block;
  float: left;
  margin: 0 4rpx 20rpx;
}
.ddf text {
  width: 120rpx;
  height: auto;
  display: block;
  float: left;
  margin: 0 0 20rpx;
  font-size: 24rpx;
  line-height: 32rpx;
  text-align: center;
  color: #000000;
}

.index {
  background: rgb(242, 242, 242);
  width: 100%;
  height: auto;
}
.jtop {
  width: 100%;
  height: 88rpx;
  background: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  box-shadow: inset 0px -1px 0px #dddddd;
}
.jtop_l {
  width: auto;
  height: 88rpx;
  display: block;
  float: left;
  font-size: 32rpx;
  color: #000000;
  line-height: 88rpx;
  margin: 0 0 0 30rpx;
}
.jtop_l image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 20rpx 0 20rpx 0;
}
.jtop_r {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: right;
  margin: 20rpx 20rpx 0 0;
}
.jtop_rl {
  margin: 20rpx 30rpx 0 0;
}
.jtop_r image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
}
.jtop_c {
  width: 70%;
  height: 48rpx;
  line-height: 48rpx;
  display: block;
  float: left;
  position: fixed;
  top: 20rpx;
  left: 15%;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
}
.jtop_c image {
  width: 36rpx;
  height: 36rpx;
  display: inline-block;
  float: none;
  margin-bottom: -5rpx;
  margin-left: 5rpx;
}
.jtop_b {
  width: 100%;
  height: auto;
  background: #ffffff;
  position: fixed;
  top: 88rpx;
  left: 0;
  z-index: 1001;
}
.jtop_bj {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
}

.ddf input {
  height: 0;
  opacity: 0;
  line-height: 0;
  min-height: 0;
}
.fjsext {
  background: none !important;
  border: 0px !important;
  content: none !important ;
  padding: 0px !important;
  margin: 0px !important;
}
.fjsext:after {
  content: none !important ;
}
</style>
